<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/4/13
  Time: 19:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
    <script type=“text/javascript” src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
    <script type=“text/javascript” src="${pageContext.request.contextPath}/js/json2.js"></script>
</head>
<body>

<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加请假条</strong></div>
    <div class="body-content">
        <form class="form-x" action="${pageContext.request.contextPath}/approveApplicationFinal.do" method="post">
            <input id="userId1" type="hidden" name="approveId" value="${approve.approveId}">
            <input type="hidden" name="userId" value="${userSession.userId}">
            <div class="form-group">
                <div class="label">
                    <label>审批者</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="${userSession.userName}" readonly data-validate="用户Id"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>审批意见：</label>
                </div>
                <div class="field">
                    <textarea class="input" style="height:120px;" name="approveOpinion" >${approve.approveOpinion}
                    </textarea>
                    <div class="tips"></div>
                </div>
            </div>


            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
                    <button class="button bg-main icon-check-square-o" type="button" onclick="return reject(${approve.approveId})"> 驳回</button>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">

                </div>
            </div>
        </form>

        <script type="text/javascript">
            function reject(approveId){
                $.ajax({
                    undefined,
                    data: "approveId=" + approveId,
                    type: "POST",
                    dataType: 'json',
                    url: "rejectApplication.do",
                    success:function (){
                        alert("驳回成功");
                        location.replace("applicationForApprovePage.do");
                    },
                    error:function (){
                        alert("驳回失败")
                    }
                })
            }

            function day() {
                var startDate = $('#startDate').val();
                var endDate = $('#endDate').val();
                var time1 = new Date(startDate).getTime();
                var time2 = new Date(endDate).getTime();
                if (time1 > time2) {
                    $('#days').attr("value", 0);
                } else if (time1 == time2) {
                    $('#days').attr("value", 1);
                } else {
                    var date = parseInt(time2 - time1);
                    var days = Math.floor(date / (24 * 60 * 60 * 1000));
                    $('#days').attr("value", days);
                }
            }
        </script>
    </div>
</div>
</body>
</html>